package bas;
import javax.swing.*;

public class StartDemo extends Thread{
    private static javax.swing.JTextArea jta = new
                   javax.swing.JTextArea(8, 20); 
    
    StartDemo(String nombre) {
        super(nombre);
    }
    
    public void run() {
        jta.append(getName() + "\tiniciado\n");
        try {
             sleep((long) (Math.random()*1500)+500);
             jta.append(getName() + "\tfinalizado\n");

        } catch (InterruptedException e) { }
    }
    
    public static void main(String[] args) {
        System.out.println("iniciando StartDemo ...");
        
        // ejecuta 3 threads
        new StartDemo("Uno").start();
        new StartDemo("Dos").start();
        new StartDemo("Tres").start();
        
        JOptionPane.showMessageDialog(null,jta,"StartDemo",JOptionPane.PLAIN_MESSAGE);
        System.out.println("... finalizando StartDemo");
        System.exit(0);
     }
}
